// API响应基础类型
export interface ApiResponse<T> {
  code: number;
  message: string;
  data: T;
}

// 分页结果类型
export interface PageResult<T> {
  records: T[];
  total: number;
  current: number;
  size: number;
  pages: number;
}

// 用户相关类型
export interface User {
  id: number;
  username: string;
  email: string;
  userClass: number;
  status: number;
  uploaded: number;
  downloaded: number;
  shareRatio: number;
  bonusPoints: number;
  passkey: string;
  createdTime: string;
  lastLoginTime: string;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  password: string;
  email: string;
  invitationCode: string;
}

export interface AuthResponse {
  token: string;
  tokenType: string;
}

// 种子相关类型
export interface Torrent {
  id: number;
  title: string;
  description: string;
  category: string;
  fileSize: number;
  seeders: number;
  leechers: number;
  finished: number;
  promotionStatus: number;
  createdTime: string;
  uploader: string;
  uploaderName?: string;
  categoryName?: string;
  size?: number;
  completedCount?: number;
  uploadedAt?: string;
  status?: number;
  promotionEndTime?: string;
}

export interface TorrentDetail extends Torrent {
  fileList: TorrentFile[];
  hasNfo: boolean;
  nfoContent?: string;
}

export interface TorrentFile {
  path: string;
  size: number;
}

// 评论类型
export interface Comment {
  id: number;
  content: string;
  userId: number;
  username: string;
  torrentId: number;
  parentId?: number;
  likes: number;
  likeCount?: number;
  isLiked?: boolean;
  createdTime: string;
  createdAt?: string;
}

// 论坛相关类型
export interface ForumSection {
  id: number;
  name: string;
  description: string;
  sortOrder: number;
  moderatorIds: string;
  topicCount?: number;
  lastPostAt?: string;
  lastPostTitle?: string;
  lastPostUser?: string;
}

export interface ForumTopic {
  id: number;
  title: string;
  content: string;
  userId: number;
  username: string;
  sectionId: number;
  sectionName: string;
  createdAt: string;
  updatedAt?: string;
  viewCount: number;
  replyCount: number;
  isTop: boolean;
  isEssence: boolean;
  isLocked: boolean;
  lastReplyAt?: string;
  lastReplyUserId?: number;
  lastReplyUsername?: string;
}

export interface ForumReply {
  id: number;
  content: string;
  topicId: number;
  userId: number;
  username: string;
  createdAt: string;
  likeCount: number;
  isLiked: boolean;
}

// 私信类型
export interface PrivateMessage {
  id: number;
  subject: string;
  content: string;
  senderId: number;
  senderUsername: string;
  receiverId: number;
  receiverUsername: string;
  isRead: boolean;
  createdTime: string;
  fromUsername?: string;
  toUsername?: string;
  title?: string;
  createdAt?: string;
}

// 求种类型
export interface Request {
  id: number;
  title: string;
  description: string;
  categoryId: number;
  categoryName?: string;
  rewardPoints: number;
  status: number; // 0: 进行中, 1: 已完成, 2: 已关闭
  userId: number;
  username: string;
  createdAt: string;
  filledAt?: string;
  filledBy?: string;
  torrentId?: number;
}

// 签到类型
export interface CheckinRecord {
  id: number;
  userId: number;
  checkinTime: string;
  rewardPoints: number;
}

export interface CheckinStatus {
  hasChecked: boolean;
  todayReward?: number;
}

// 邀请码类型
export interface InvitationCode {
  id: number;
  code: string;
  createdBy: number;
  createdTime: string;
  createTime?: string;
  usedBy?: number;
  usedTime?: string;
  usedByUsername?: string;
  isUsed: boolean;
  used?: boolean;
}

// 管理员统计类型
export interface AdminStats {
  totalUsers: number;
  activeUsers: number;
  totalTorrents: number;
  totalUpload: string;
  totalDownload: string;
  onlinePeers: number;
}

// 用户等级映射
export const USER_CLASS_MAP = {
  0: { text: '未验证', color: 'default' },
  1: { text: '普通用户', color: 'blue' },
  2: { text: 'VIP用户', color: 'green' },
  3: { text: '资深用户', color: 'geekblue' },
  4: { text: '审核员', color: 'purple' },
  5: { text: '管理员', color: 'gold' },
  9: { text: '超级管理员', color: 'red' }
};

// 用户状态映射
export const USER_STATUS_MAP = {
  0: { text: '正常', status: 'success' },
  1: { text: '禁用', status: 'error' },
  2: { text: '待验证', status: 'warning' }
};

// 种子状态映射
export const TORRENT_STATUS_MAP = {
  0: { text: '待审核', color: 'orange' },
  1: { text: '正常', color: 'green' },
  2: { text: '已删除', color: 'red' }
};

// 推广状态映射
export const PROMOTION_STATUS_MAP = {
  0: { text: '无推广', color: '' },
  1: { text: '免费下载', color: 'green' },
  2: { text: '2x上传', color: 'blue' },
  3: { text: '2x下载', color: 'red' },
  4: { text: '50%下载', color: 'purple' }
}; 